package com.munhrasoft.elearning.business.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findAllClasses", query = "SELECT c FROM CourseClass c"),
    @NamedQuery(name = "findClassesByTitle", query = "SELECT c FROM CourseClass c WHERE lower(c.title) "
            + "LIKE :title") })
@SequenceGenerator(name = "classesSeq", initialValue = 1, allocationSize = 1)
public class CourseClass {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "classesSeq")
    private Long            id;
    private String          title;
    private String          videourl;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Exercises> exercises;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<Exercises> getExercises() {
        return exercises;
    }

    public void setExercises(List<Exercises> exercises) {
        this.exercises = exercises;
    }

    public String getVideourl() {
        return videourl;
    }

    public void setVideourl(String videourl) {
        this.videourl = videourl;
    }

}
